<template>
	<view class='product-action bg-color-item'>
		<view class="button flex-center-sb">
			<w-button v-if="info.product.weither_resale==0 && info.status==1" class="flex-1 ml-16" @click="consignment">立即寄售</w-button>
			<!-- <w-button shape="circle" v-if="info.product.weither_regift==0 && info.status==1" class="flex-1 ml-16">立即转增</w-button> -->
			<w-button disabled v-if="info.status==2 && info.product.is_lock==1" class="flex-1 ml-16">锁定中</w-button>
			<w-button v-if="info.status==2 && info.product.is_lock!=1" class="flex-1 ml-16" @click="cancel_consignment_pop=true">取消寄售</w-button>
		</view>
		<w-toast v-model="cancel_consignment_pop" contentAlign="center" content="确认取消此寄售？" @action='cancelConsignment'></w-toast>
	</view>
</template>  

<script>
	import { changeMarketGoods } from '@/api/market/index.js';
	export default {
		props:{
			info:{
				type: Object
			}
		},
		data() {
			return {
				cancel_consignment_pop:false
			};
		},
		methods:{
			// 立即寄售
			consignment() {
				uni.$u.route('/pages/consignments/consignments',{id:this.info.id,pageType:2})
			},
			
			// 取消寄售
			cancelConsignment(e) {
				if(!e) return
				uni.showLoading()
				changeMarketGoods({ id:this.info.market_goods.id }).then(()=>{
					this.$emit('refresh')
				}).catch(()=>{})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.product-action {
		width: 750rpx;
		position: fixed;
		left: 0;
		bottom: 0;
		padding-bottom: env(safe-area-inset-bottom);
		>.button{
			padding: 12rpx 32rpx 12rpx 0;
		}
	}
	.btn_style{
		
	}
</style>
